package com.cy.java.享元模式;

import java.util.HashMap;

/*工厂类,  用于对类进行存储和管理*/

public class ShapeFactory {

    private static final HashMap<String, Shape> map = new HashMap<>();

    public static Shape getCircle(String color){
        Circle circle = (Circle) map.get(color);

        if(circle == null){
            circle = new Circle(color);
            map.put(color, circle);
            System.out.println("添加的圆的颜色为: " + color);
        }
        return circle;
    }

}
